package com.hyacinth.controller;

import com.hyacinth.model.OrderInfo;
import com.hyacinth.serive.TestService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

//@RequestMapping("/nacos")
@RestController
public class TestController {
    @Autowired
    private TestService testService;

    @Resource
    private RestTemplate restTemplate;

    @RequestMapping("/{orderId}")
    public OrderInfo getOrderById(@PathVariable("orderId") Integer orderId) {
        return testService.selectOrderById(orderId);
    }

    @RequestMapping("/test")
    public String getOrderById2() {
        String url = "http://test-service/test2";
        String str = restTemplate.getForObject(url, String.class);
        return str;
    }

    @RequestMapping("/test2")
    public String getOrderById3() {
        return "123";
    }
}
